< previous page page_397 next page >

Page 397
Let My Object Go!
When an ASP page requires an object from a DLL, the Internet Information Server (IIS) loads the DLL into memory. Once the object is no longer needed, the DLL is released. Maybe. Sometimes.
When does IIS actually unload the DLL? It depends on how you have ASP configured. If you are running the object within the IIS process, it can take some time. That can make life difficult when you need to modify, recompile, and test your code.
What happens when you try to compile a DLL that is loaded by IIS? The compilation failsVisual Basic cannot write the DLL file because it is locked by IIS.
In these situations, in order to successfully compile the application you must stop the IIS services, do the compilation, then restart the services.
Now, stopping and restarting services is not hard to do. It may be possible to do it through the Internet Control Manager. However, the IIS4 Internet Control Manager does not make it obvious how this can be accomplished (it was much easier with IIS3). Sure, it's easy to stop or start individual Web sites, but stopping the overall service and the administration service as well is not intuitive.
An easier approach is to use the service manager from the Control Panel. You need to stop both the World Wide Web service and the IIS administration service. It's easy, but annoying, because the service manager only allows you to start or stop one service at a time. And since it takes several seconds for each one, the whole process of starting or stopping a service takes about five or six seconds, sometimes more depending on the system configuration.
It seemed to me that it would be very useful to have a utility that could start or stop any selection of services in one operation and quickly toggle them back to their original state.
The Design
I'm a big believer in the importance of good design, even when dealing with relatively simple utilities. You never know when that simple utility is going to become one of those pieces of code that lingers on forever, and a small investment in design ahead of time can mean the difference between something that evolves into a buggy kludge and something that becomes a permanent (and reusable) part of your code library.
Let's start by considering the tasks we need to perform:
Obtain a list of services.
Obtain the current running state of a service.

 
< previous page page_397 next page >